package cn.bincker.mybatis.encrypt.type;

import com.baomidou.mybatisplus.core.toolkit.LambdaUtils;
import com.baomidou.mybatisplus.core.toolkit.support.LambdaMeta;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import org.apache.ibatis.reflection.property.PropertyNamer;

public class LambdaEncryptParam<T> extends EncryptParam<T>{
    public LambdaEncryptParam(Class<T> cls, SFunction<T, ?> lambda, Object value) {
        this(cls, lambda, null, value);
    }
    public LambdaEncryptParam(Class<T> cls, SFunction<T, ?> lambda, Object target, Object value) {
        super(cls, LambdaUtils.extract(lambda).getImplMethodName(), target, value);
    }
    public LambdaEncryptParam(SFunction<T, ?> lambda, Object value) {
        this(LambdaUtils.extract(lambda), null, value);
    }
    public LambdaEncryptParam(SFunction<T, ?> lambda, Object target, Object value) {
        this(LambdaUtils.extract(lambda), target, value);
    }
    public LambdaEncryptParam(LambdaMeta lambdaMeta, Object target, Object value) {
        //noinspection unchecked
        super((Class<T>) lambdaMeta.getInstantiatedClass(), PropertyNamer.methodToProperty(lambdaMeta.getImplMethodName()), target, value);
    }
}
